<!--桌面快捷方式-->
<template>
  <div class="speedy-manage">
    <a-card size="small" :headStyle="{ background: '#f9f9f9' }" :bodyStyle="{ height: 'calc(100% - 48px)' }">
      <div slot="title">
        <div class="top-icon">
          <icon-font type="icon-kuaijie" />
        </div>
        <span>桌面快捷方式</span>
      </div>
      <div slot="extra">
        <a-button type="primary" icon="plus" @click="speedyClick('add')">新增快捷方式</a-button>
      </div>
      <!-- 桌面快捷方式表格 -->
      <el-table
        :data="speedyTableData"
        highlight-current-row
        border
        height="100%"
        :row-style="{height:'40px'}"
        :cell-style="{padding:'0px'}"
        :header-cell-style="{background: '#FAFAFA', padding: 0, height: '40px', color: '#666666'}"
        style="width: 100%">
        <slot v-for="(item,index) in speedyColumns">
          <el-table-column
            :key="index"
            :property="item.field"
            :label="item.title"
            :width="item.width"
            show-overflow-tooltip
            sortable>
          </el-table-column>
        </slot>
        <el-table-column label="操作">
          <template>
            <a @click="speedyClick('edit')">编辑</a>
            <a-divider type="vertical" />
            <a @click="speedyClick('del')">删除</a>
          </template>
        </el-table-column>
      </el-table>
    </a-card>

    <!-- 桌面快捷方式弹出框 -->
    <a-modal
      :maskClosable="false"
      :title="modalTitle"
      v-model="dialogFormVisible">
      <a-form
        :label-col="{ span: 6 }"
        :wrapper-col="{ span: 18 }"
        :form="form">
        <a-form-item label="顺序号">
          <a-input type="number" v-decorator="[ 'SC_Order', {rules: [{ required: true, message: '请输入顺序号!' }]} ]" />
        </a-form-item>
        <a-form-item label="快捷菜单名称">
          <a-input v-decorator="[ 'SC_ShortCutName', {rules: [{ required: true, message: '请输入快捷菜单名称!' }]} ]" />
        </a-form-item>
        <a-form-item label="快捷菜单路径">
          <a-input v-decorator="[ 'SC_RoutePath', {rules: [{ required: true, message: '请输入快捷菜单路径!' }]} ]" />
        </a-form-item>
        <a-form-item label="图标名称">
          <a-input v-decorator="[ 'SC_BackgroundIcon', {rules: [{ required: true, message: '请输入图标名称!' }]} ]" />
        </a-form-item>
        <a-form-item label="图标背景颜色">
          <el-color-picker v-decorator="[ 'SC_ShortCutBackGround', {initialValue: '#4189FF'} ]"></el-color-picker>
        </a-form-item>
        <a-form-item label="备注">
          <a-input type="textarea" v-decorator="[ 'SC_Remark' ]" />
        </a-form-item>
      </a-form>
    </a-modal>
  </div>
</template>

<script>
export default {
  name: 'SpeedyManage',
  components: {
  },
  data () {
    return {
      modalTitle: '', // 桌面快捷方式弹出框标题
      dialogFormVisible: false, // 桌面快捷方式显示与隐藏
      form: this.$form.createForm(this),
      speedyTableData: [
        {
          SC_Order: '1',
          SC_ShortCutName: '用户管理',
          SC_RoutePath: 'user',
          SC_BackgroundIcon: 'user',
          SC_ShortCutBackGround: '#4189FF',
          SC_U_ID: 'admin',
          SC_Remark: '测试数据'
        }
      ], // 桌面快捷方式表格数据
      speedyColumns: [ // 桌面快捷方式表头数据
        {
          title: '顺序号',
          field: 'SC_Order'
        },
        {
          title: '快捷菜单名称',
          field: 'SC_ShortCutName'
        },
        {
          title: '快捷菜单路径',
          field: 'SC_RoutePath'
        },
        {
          title: '图标',
          field: 'SC_BackgroundIcon'
        },
        {
          title: '图标背景颜色',
          field: 'SC_ShortCutBackGround'
        },
        {
          title: '用户名',
          field: 'SC_U_ID'
        },
        {
          title: '备注',
          field: 'SC_Remark'
        }
      ]
    }
  },
  created () {
  },
  mounted () {
  },
  methods: {
    // 桌面快捷方式按钮事件 val代表类型，add：快捷方式新增，edit：快捷方式编辑，del：快捷方式删除
    speedyClick (val) {
      switch (val) {
        case 'add':
          this.modalTitle = '快捷方式新增'
          this.dialogFormVisible = true
          this.form.resetFields() // 表单清空
          break
        case 'edit':
          this.modalTitle = '快捷方式编辑'
          this.dialogFormVisible = true
          break
        case 'del':
          var this_ = this
          this.$confirm({
            title: '提示',
            content: '此操作将永久删除该文件, 是否继续?',
            okText: '确认',
            cancelText: '取消',
            onOk () {
              this_.$message.success('删除成功')
            }
          })
          break
        default:
          break
      }
    }
  }
}
</script>
<style lang="less" scoped>
.speedy-manage {
  width: 100%;
  height: 100%;
  padding: 10px 10px 0;
  background: #f0f2f5;
}
</style>
